/***********************************************
/gen auto by zuitools
***********************************************/
#include "Charge2Activity.h"

/*TAG:GlobalVariable全局变量*/
static ZKTextView* mTextTimePtr;
static ZKTextView* mTextPaymothimgPtr;
static ZKTextView* mTextCoastPtr;
static ZKTextView* mLabelQrCodePicPtr;
static ZKTextView* mText_1Ptr;
static ZKButton* mBtnAliPayPtr;
static ZKButton* mBtnWeCharPayPtr;
static ZKButton* msys_backPtr;
static ZKTextView* mLabel_7Ptr;
static ZKSeekBar* mSeekchargePtr;
static ZKTextView* mLabel_6Ptr;
static ZKTextView* mtextPayMathPtr;
static ZKTextView* mLabel_3Ptr;
static ZKWindow* mView_1Ptr;

/*register activity*/
REGISTER_ACTIVITY(Charge2Activity);

#include "logic/Charge2Logic.cc"

/***********/
typedef struct {
    int id;
    const char *pApp;
} SAppInfo;

/**
 *点击跳转window
 */
static SAppInfo sAppInfoTab[] = {
//  { ID_MAIN_TEXT, "TextViewActivity" },
};

/***************/
typedef bool (*ButtonCallback)(ZKButton *pButton);
/**
 * button onclick表
 */
typedef struct {
    int id;
    ButtonCallback callback;
}S_ButtonCallback;

/*TAG:ButtonCallbackTab按键映射表*/
static S_ButtonCallback sButtonCallbackTab[] = {
    ID_CHARGE2_BtnAliPay, onButtonClick_BtnAliPay,
    ID_CHARGE2_BtnWeCharPay, onButtonClick_BtnWeCharPay,
    ID_CHARGE2_sys_back, onButtonClick_sys_back,
};
/***************/


typedef void (*SeekBarCallback)(ZKSeekBar *pSeekBar, int progress);
typedef struct {
    int id;
    SeekBarCallback callback;
}S_ZKSeekBarCallback;
/*TAG:SeekBarCallbackTab*/
static S_ZKSeekBarCallback SZKSeekBarCallbackTab[] = {
    ID_CHARGE2_Seekcharge, onProgressChanged_Seekcharge,
};


typedef int (*ListViewGetItemCountCallback)(const ZKListView *pListView);
typedef void (*ListViewobtainListItemDataCallback)(ZKListView *pListView,ZKListView::ZKListItem *pListItem, int index);
typedef void (*ListViewonItemClickCallback)(ZKListView *pListView, int index, int id);
typedef struct {
    int id;
    ListViewGetItemCountCallback getListItemCountCallback;
    ListViewobtainListItemDataCallback obtainListItemDataCallback;
    ListViewonItemClickCallback onItemClickCallback;
}S_ListViewFunctionsCallback;
/*TAG:ListViewFunctionsCallback*/
static S_ListViewFunctionsCallback SListViewFunctionsCallbackTab[] = {
};


typedef void (*SlideWindowItemClickCallback)(ZKSlideWindow *pSlideWindow, int index);
typedef struct {
    int id;
    SlideWindowItemClickCallback onSlideItemClickCallback;
}S_SlideWindowItemClickCallback;
/*TAG:SlideWindowFunctionsCallbackTab*/
static S_SlideWindowItemClickCallback SSlideWindowItemClickCallbackTab[] = {
};

Charge2Activity::Charge2Activity() {
	//todo add init code here
}

Charge2Activity::~Charge2Activity() {
	//todo add init file here
    // 退出应用时需要反注册
    EASYUICONTEXT->unregisterGlobalTouchListener(this);
    onUI_quit();
}

const char* Charge2Activity::getAppName() const{
	return "Charge2.ftu";
}

//TAG:onCreate
void Charge2Activity::onCreate() {
	Activity::onCreate();
    mTextTimePtr = (ZKTextView*)findControlByID(ID_CHARGE2_TextTime);
    mTextPaymothimgPtr = (ZKTextView*)findControlByID(ID_CHARGE2_TextPaymothimg);
    mTextCoastPtr = (ZKTextView*)findControlByID(ID_CHARGE2_TextCoast);
    mLabelQrCodePicPtr = (ZKTextView*)findControlByID(ID_CHARGE2_LabelQrCodePic);
    mText_1Ptr = (ZKTextView*)findControlByID(ID_CHARGE2_Text_1);
    mBtnAliPayPtr = (ZKButton*)findControlByID(ID_CHARGE2_BtnAliPay);
    mBtnWeCharPayPtr = (ZKButton*)findControlByID(ID_CHARGE2_BtnWeCharPay);
    msys_backPtr = (ZKButton*)findControlByID(ID_CHARGE2_sys_back);
    mLabel_7Ptr = (ZKTextView*)findControlByID(ID_CHARGE2_Label_7);
    mSeekchargePtr = (ZKSeekBar*)findControlByID(ID_CHARGE2_Seekcharge);if(mSeekchargePtr!= NULL){mSeekchargePtr->setSeekBarChangeListener(this);}
    mLabel_6Ptr = (ZKTextView*)findControlByID(ID_CHARGE2_Label_6);
    mtextPayMathPtr = (ZKTextView*)findControlByID(ID_CHARGE2_textPayMath);
    mLabel_3Ptr = (ZKTextView*)findControlByID(ID_CHARGE2_Label_3);
    mView_1Ptr = (ZKWindow*)findControlByID(ID_CHARGE2_View_1);
	onUI_init();
        // 注册监听全局触摸
    EASYUICONTEXT->registerGlobalTouchListener(this);

    // 如果需要定时器功能，可以打开下面部分代码，然后在onTimer里面响应；参数0是id，1是时间间隔ms
    registerTimer(0, 100);

}

void Charge2Activity::onClick(ZKBase *pBase) {
	//TODO: add widget onClik code 
    int buttonTablen = sizeof(sButtonCallbackTab) / sizeof(S_ButtonCallback);
    for (int i = 0; i < buttonTablen; ++i) {
        if (sButtonCallbackTab[i].id == pBase->getID()) {
            sButtonCallbackTab[i].callback(pBase);
            break;
        }
    }


    int len = sizeof(sAppInfoTab) / sizeof(sAppInfoTab[0]);
    for (int i = 0; i < len; ++i) {
        if (sAppInfoTab[i].id == pBase->getID()) {
            EASYUICONTEXT->openActivity(sAppInfoTab[i].pApp);
            return;
        }
    }

	Activity::onClick(pBase);
}

void Charge2Activity::onResume() {
	Activity::onResume();
}

void Charge2Activity::onPause() {
	Activity::onPause();
}

void Charge2Activity::onIntent(const Intent *intentPtr) {
	//TODO:  
	onUI_Intent(intentPtr);
	Activity::onIntent(intentPtr);
}

bool Charge2Activity::onTimer(int id) {
	return onUI_Timer(id);
}

void Charge2Activity::onProgressChanged(ZKSeekBar *pSeekBar, int progress){

    int seekBarTablen = sizeof(SZKSeekBarCallbackTab) / sizeof(S_ZKSeekBarCallback);
    for (int i = 0; i < seekBarTablen; ++i) {
        if (SZKSeekBarCallbackTab[i].id == pSeekBar->getID()) {
            SZKSeekBarCallbackTab[i].callback(pSeekBar, progress);
            break;
        }
    }
}

int Charge2Activity::getListItemCount(const ZKListView *pListView) const{
    int tablen = sizeof(SListViewFunctionsCallbackTab) / sizeof(S_ListViewFunctionsCallback);
    for (int i = 0; i < tablen; ++i) {
        if (SListViewFunctionsCallbackTab[i].id == pListView->getID()) {
            return SListViewFunctionsCallbackTab[i].getListItemCountCallback(pListView);
            break;
        }
    }
    return 0;
}

void Charge2Activity::obtainListItemData(ZKListView *pListView,ZKListView::ZKListItem *pListItem, int index){
    int tablen = sizeof(SListViewFunctionsCallbackTab) / sizeof(S_ListViewFunctionsCallback);
    for (int i = 0; i < tablen; ++i) {
        if (SListViewFunctionsCallbackTab[i].id == pListView->getID()) {
            SListViewFunctionsCallbackTab[i].obtainListItemDataCallback(pListView, pListItem, index);
            break;
        }
    }
}

void Charge2Activity::onItemClick(ZKListView *pListView, int index, int id){
    int tablen = sizeof(SListViewFunctionsCallbackTab) / sizeof(S_ListViewFunctionsCallback);
    for (int i = 0; i < tablen; ++i) {
        if (SListViewFunctionsCallbackTab[i].id == pListView->getID()) {
            SListViewFunctionsCallbackTab[i].onItemClickCallback(pListView, index, id);
            break;
        }
    }
}

void Charge2Activity::onSlideItemClick(ZKSlideWindow *pSlideWindow, int index) {
    int tablen = sizeof(SSlideWindowItemClickCallbackTab) / sizeof(S_SlideWindowItemClickCallback);
    for (int i = 0; i < tablen; ++i) {
        if (SSlideWindowItemClickCallbackTab[i].id == pSlideWindow->getID()) {
            SSlideWindowItemClickCallbackTab[i].onSlideItemClickCallback(pSlideWindow, index);
            break;
        }
    }
}

bool Charge2Activity::onTouchEvent(const MotionEvent &ev) {
    return onCharge2ActivityTouchEvent(ev);
}
